function is_user(){
    //获取用户信息
let user_id = getCookie("user_id")
let token = getCookie("token")
let $log_out = $(".log_out")
if (user_id && token) {
    $log_out.css({ display: "block" })
    load_user(user_id, token)
}
function load_user(id, token) {
    let $login_info = $(".login_info")
    let $register_info = $(".register_info")
    let options = {
        url: "http://127.0.0.1:8888/users/info/" + id,
        type: "GET",
        datatype: "json",
        data: {
            id: id
        },
        headers: {
            authorization: token
        }
    }
    $.ajax(options)
        .done(function (data) {
            console.log(data);
            $register_info.html(data.info.nickname).css({ color: "#00d7dc" })
            $login_info.html(data.info.username).css({ color: "orangered" })
        })
}
//注销登录

$log_out.click(function () {
    let user_id = getCookie("user_id")
    let token = getCookie("token")
    if (user_id && token) {
        logout_user(user_id, token)
    }
})
function logout_user(id, token) {
    let options = {
        url: "http://127.0.0.1:8888/users/logout/" + id,
        type: "GET",
        data: {
            id: id,
        },
        datatype: "json",
    }
    $.ajax(options)
        .done(function (data) {
            console.log(data);
            if (data.code === 1) {
                removeCookie("user_id");
                removeCookie("token");
                location.reload();
            }
        })
}
}